﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AgileDashboard.Services;
using PlanningPokerMVC.Models;
using AgileDashboard.Entities;
using PlanningPokerMVC.Helpers;
using System.Web.UI.WebControls;

namespace PlanningPokerMVC.Controllers
{
    public class SettingsController : Controller
    {
        //
        // GET: /DashboardSettings/

        public ActionResult Index()
        {
            return View();
        }

        [AcceptVerbs(HttpVerbs.Get)]
        public JsonResult Projects()
        {

            TfsDataLoaderService service = new TfsDataLoaderService();

            //Project proj = service.GetTeamProjectByName("Max Phase 2");


            List<TfsProject> projects = service.GetTeamProjects();

            List<TfsQuery> queries = service.GetQueries(499);

            SettingsViewModel viewModel = new SettingsViewModel();
            viewModel.Projects = projects;
            //viewModel.Queries = queries;



            return Json(viewModel.Projects, JsonRequestBehavior.AllowGet);

        }


        [AcceptVerbs(HttpVerbs.Get)]
        public JsonResult Queries()
        {

            TfsDataLoaderService service = new TfsDataLoaderService();

            //Project proj = service.GetTeamProjectByName("Max Phase 2");


            List<TfsProject> projects = service.GetTeamProjects();

            List<TfsQuery> queries = service.GetQueries(499);

            SettingsViewModel viewModel = new SettingsViewModel();
            viewModel.Projects = projects;
            viewModel.Queries = queries;



            return Json(viewModel.Queries, JsonRequestBehavior.AllowGet);

        }

        [HttpGet]
        public ActionResult WorkItemSync()
        {

            //WorkItemService wiService = new WorkItemService();
            //wiService.SyncWorkItems();



            return View();
            //return View(viewModel);
        }



    }
}
